/* Author: Mark Mckillion
 * Student ID: B00540772
 * Date: 07/03/2012
 * Version 1.0.*/
package assignment3;

import javax.swing.*;
import java.awt.*;

@SuppressWarnings("serial")
public class ModelFrame extends JFrame
{   /*This class will crate a JFrame that will hold two panels. One panel will be
     *a DrawingPanel to show the graphical output and the other will be a ControlPanel
     *which will control the user input.*/
    
    //create the two panels.
    protected static DrawingPanel drawing = new DrawingPanel();
    private ControlPanel control = new ControlPanel();
    
    //Create a text panel that it going to be used to provide instructions to the user.
    private JTextArea instructions = new JTextArea();
            
    {   //Set the layout to the frame in order to show the panels, BorderLayout used.
        setLayout(new BorderLayout());
        
        //program will stop running when "X" is pressed.
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        
        //set the title for the program.
        this.setTitle("Financial Modeller - B00540772");
                
        //add the two frames to the frame show that they will show in the correct areas.
        this.add(drawing, BorderLayout.NORTH);
        this.add(control, BorderLayout.SOUTH);
        
        //add the instructions panel into the frame.
        this.add(instructions, BorderLayout.CENTER);
        
        //set the size of the two panels.
        drawing.setPreferredSize(new Dimension(900,350));
        control.setPreferredSize(new Dimension(900,250));
        instructions.setPreferredSize(new Dimension(900,80));
        
        //set the background of the DrawingPanel to highlight the two different panels.
        drawing.setBackground(Color.WHITE);
        
        //call the line wrap method to improve the layout of the text area.
        instructions.setLineWrap(true);
        
        //insert the instructions for the user.
        instructions.append("Please use the control panel to enter your financial"
                + " information. When the information has been entered press 'Start'"
                + " to run the simulation. The textual output will          show each"
                + " input and output as it happens, and will give you a balance update."
                + " The graphical output will give you a representation of the changing"
                + " weekly balance,       each second represents"
                + " one week. Please be aware that if the balance goes above £16000"
                + " or the duration goes above 52 weeks the graphical output will stop,"
                + " if         this happens you can continue to use the textual output."
                + " If you do not wish to use all of the threads please leave amount AND"
                + " frequency as '0' and that thread will not    start.");
        
        
        //set visible and pack to ensure it will run correctly.
        pack();
        setVisible(true);	
    }
}
